< previous page page_635 next page >

Page 635
adLockReadOnlySets data in the recordset as read only
adLockPessimisticProvides pessimistic record locking, which means the record is locked while you are editing it
adLockOptimisitcProvides optimistic record locking, which means records are locked only when you call the Update method
adLockBatchOptimisitcUpdates multiple records at a time with the UpdateBatch method
Why are the parameters named after attitudes (optimistic and pessimistic)? Because attempting to update a locked record causes an error in your program. You can be optimistic that a record will be available when you need to update it, or pessimistic and lock it for as long as you need it.
Viewing Others' Changes
Another concern with multiuser databases is making sure the data in your recordset is as accurate as it needs to be. If you recall an earlier section, you know that the CursorType property can restrict recordset navigation. However, the main point of the different cursor types, listed in Table 28.3, is to control how your recordset is linked to the underlying data.
Table 28.3 The CursorType Property
ConstantDescription
adOpenForwardOnlyThis property is fast but allows only forward movement.
adOpenKeySetYour program can see some of the data changes made by other users.
adOpenDynamicYour program can see all the data changes made by other users.
adOpenStaticThis property provides a static picture of the database; you cannot see others' changes.

As you will find out from using ADO, not all cursor types are supported by all databases. For Access databases, the default adOpenForwardOnly cursor is intended for a quick read-only pass through the database, whereas the adOpenKeySet cursor is better suited for updates and more complex operations.
Adding New Data
Adding new records to a Recordset object is similar to changing the content of existing records, but with one extra step:
1. Call the AddNew method.
2. Assign values to the fields.
3. Call the Update method.

 
< previous page page_635 next page >